package org.dean.webapps.projectname.presentation.utils;

/**
 * Created by IntelliJ IDEA.
 * User: v_yina01
 * Date: 8/26/11
 * Time: 10:09 AM
 * To change this template use File | Settings | File Templates.
 */
public class RegisterInfoCheckUtils {
    public static boolean checkIsEmail(String email){
        if (email != null
                && email
                        .matches("^([0-9a-zA-Z]+[_.0-9a-zA-Z-]+)@([a-zA-Z0-9-]+[.])+([a-zA-Z]{2,3})$")) {
            return true;
        } else {
            return false;
        }
    }

    public static boolean checkIsPhone(String phone){
        if (phone != null || !"".equals(phone)) {
            if (phone.trim()
                    .matches("\\(?[0-9]{3}\\)?[- ]?[0-9]{3}[- ]?[0-9]{4}")) {
                return true;
            } else {
                return false;
            }
        } else {
            return false;
        }
    }

    public static boolean checkUserName(String userName){
        if (userName != null && userName.matches("[0-9_a-zA-Z]*")) {
            return true;
        } else {
            return false;
        }
    }

    public static boolean checkFirstName(String name){
        if (name != null && name.matches("[0-9_a-zA-Z]*")) {
            return true;
        } else {
            return false;
        }
    }
    public static boolean checkLastName(String name){
        if (name != null && name.matches("[0-9_a-zA-Z]*")) {
            return true;
        } else {
            return false;
        }
    }
    public static boolean checkReenterPassword(String password, String rePassword){

        if(null != password && null != rePassword){
            if(password.equals(rePassword)){
                return true;
            } else {
              return false;
            }
        } else {
            return false;
        }
    }
}
